home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntinc20 / stdio.h < prev    next >
C/C++ Source or Header  |  1992-05-17  |  6KB  |  195 lines

  1. /*
  2.  *
  3.  *    STDIO.H        Standard i/o include file
  4.  *
  5.  */
  6.  
  7. #ifndef _STDIO_H
  8. #define    _STDIO_H
  9.  
  10. #ifndef _COMPILER_H
  11. #include <compiler.h>
  12. #endif
  13.  
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17.  
  18. #ifndef _SIZE_T
  19. #define _SIZE_T __SIZE_TYPEDEF__
  20. typedef _SIZE_T size_t;
  21. #endif
  22.  
  23. /*
  24.  *    CONSTANTS:
  25.  */
  26.  
  27. #define    _NFILE        (20)        /* maximum number of open streams */
  28. #define FOPEN_MAX    _NFILE
  29. #define    FILENAME_MAX    (128)        /* maximum filename size */
  30.  
  31. #ifndef NULL
  32. #define NULL        __NULL
  33. #endif
  34.  
  35. #define    BUFSIZ        ((size_t)1024)    /* default buffer size */
  36.             /* change here must be reflected in crt0.c too */
  37.  
  38. #define    EOF        (-1)        /* end-of-file indicator */
  39. #ifndef __STRICT_ANSI__
  40. # ifndef _POSIX_SOURCE
  41. #define    EOS        '\0'        /* end-of-string indicator */
  42. # endif
  43. #endif
  44.  
  45. #ifndef SEEK_SET
  46. /* lseek() origins */
  47. #define    SEEK_SET    0        /* from beginning of file */
  48. #define    SEEK_CUR    1        /* from current location */
  49. #define    SEEK_END    2        /* from end of file */
  50. #endif
  51.  
  52. /* FILE structure flags */
  53. #define    _IOREAD        0x0001        /* file may be read from */
  54. #define    _IOWRT        0x0002        /* file may be written to */
  55. #define    _IOBIN        0x0004        /* file is in "binary" mode */
  56. #define    _IODEV        0x0008        /* file is a character device */
  57. #define    _IORW        0x0080        /* file is open for update (r+w) */
  58. #define    _IOFBF        0x0100        /* i/o is fully buffered */
  59. #define    _IOLBF        0x0200        /* i/o is line buffered */
  60. #define    _IONBF        0x0400        /* i/o is not buffered */
  61. #define    _IOMYBUF    0x0800        /* standard buffer */
  62. #define    _IOEOF        0x1000        /* EOF has been reached */
  63. #define    _IOERR        0x4000        /* an error has occured */
  64. #define _IOSTRING    0x8000        /* really a string buffer   */
  65.  
  66. typedef    struct            /* FILE structure */
  67.     {
  68.     long        _cnt;        /* # of bytes in buffer */
  69.     unsigned char    *_ptr;        /* current buffer pointer */
  70.     unsigned char    *_base;        /* base of file buffer */
  71.     unsigned int    _flag;        /* file status flags */
  72.     int        _file;        /* file handle */
  73.     long        _bsiz;        /* buffer size */
  74.     unsigned char    _ch;        /* tiny buffer, for "unbuffered" i/o */
  75.     }
  76.     FILE;
  77.  
  78. /* object of type capable of recording uniquely every position in a file */
  79. typedef unsigned long fpos_t;
  80.  
  81. #define    L_tmpnam    128
  82. #define    TMP_MAX        100
  83.  
  84. extern    FILE    _iob[];
  85.  
  86. /* standard streams */
  87. #define stdin    (&_iob[0])
  88. #define stdout    (&_iob[1])
  89. #define stderr    (&_iob[2])
  90.  
  91. /* stream macros */
  92. #define clearerr(fp)    ((void) ((fp)->_flag &= ~(_IOERR|_IOEOF)))
  93. #define feof(fp)    ((fp)->_flag & _IOEOF)
  94. #define ferror(fp)    ((fp)->_flag & _IOERR)
  95. #define fileno(fp)    ((fp)->_file)
  96.  
  97.  
  98. /* function definitions */
  99.  
  100. __EXTERN int    remove    __PROTO((const char *));
  101. __EXTERN int    rename    __PROTO((const char *, const char *));
  102. __EXTERN char *    tmpnam    __PROTO((char *));
  103. __EXTERN FILE *    tmpfile    __PROTO((void));
  104.  
  105. __EXTERN int    fclose    __PROTO((FILE *));
  106. __EXTERN int    fflush    __PROTO((FILE *));
  107.  
  108. __EXTERN FILE *    fopen    __PROTO((const char *, const char *));
  109. __EXTERN FILE *    freopen    __PROTO((const char *, const char *, FILE *));
  110.  
  111. __EXTERN void    setbuf    __PROTO((FILE *, char *));
  112. __EXTERN int    setvbuf    __PROTO((FILE *, char *, int, size_t));
  113.  
  114. #ifdef __SRC__
  115. __EXTERN int    fscanf    __PROTO((FILE *, const char *, char *));
  116. __EXTERN int    scanf    __PROTO((const char *, char *));
  117. __EXTERN int     sscanf    __PROTO((const char *, const char *, int));
  118. #else
  119. __EXTERN int    fscanf    __PROTO((FILE *, const char *, ...));
  120. __EXTERN int    scanf    __PROTO((const char *, ...));
  121. __EXTERN int    sscanf    __PROTO((const char *, const char *, ...));
  122. #endif
  123.  
  124. __EXTERN int    fprintf    __PROTO((FILE *, const char *, ...));
  125. __EXTERN int    printf    __PROTO((const char *, ...));
  126. __EXTERN int    sprintf    __PROTO((char *, const char *, ...));
  127.  
  128. __EXTERN int     vfprintf __PROTO((FILE *, const char *, __VA_LIST__));
  129. __EXTERN int     vprintf     __PROTO((const char *, __VA_LIST__));
  130. __EXTERN int     vsprintf __PROTO((char *, const char *, __VA_LIST__));
  131.  
  132. __EXTERN int    fgetc    __PROTO((FILE *));
  133. __EXTERN char    *fgets    __PROTO((char *, int, FILE *));
  134. __EXTERN char    *gets    __PROTO((char *));
  135. __EXTERN int    fputc    __PROTO((int c, FILE *));
  136. __EXTERN int    fputs    __PROTO((const char *, FILE *));
  137. __EXTERN int    puts    __PROTO((const char *));
  138. __EXTERN int     fungetc    __PROTO((int, FILE *));
  139.  
  140. __EXTERN size_t    fread    __PROTO((void *, size_t, size_t, FILE *));
  141. __EXTERN size_t    fwrite    __PROTO((const void *, size_t, size_t, FILE *));
  142.  
  143. __EXTERN int    fgetpos    __PROTO((FILE *, fpos_t *));
  144. __EXTERN int    fsetpos    __PROTO((FILE *, fpos_t *));
  145.  
  146. __EXTERN int    fseek    __PROTO((FILE *, long, int));
  147. __EXTERN long    ftell    __PROTO((FILE *));
  148. __EXTERN void    rewind    __PROTO((FILE *));
  149.  
  150. __EXTERN void    perror    __PROTO((const char *));
  151.  
  152. #ifndef __STRICT_ANSI__
  153. __EXTERN FILE    *fdopen    __PROTO((int, const char *));
  154. __EXTERN FILE    *popen    __PROTO((const char *, const char *));
  155. __EXTERN int    pclose    __PROTO((FILE *));
  156.  
  157. # ifndef _POSIX_SOURCE
  158. __EXTERN void    _binmode    __PROTO((int));        /* ++jrb */
  159. __EXTERN long     getl    __PROTO((FILE *));
  160. __EXTERN long     putl    __PROTO((long, FILE *));
  161. __EXTERN short     getw    __PROTO((FILE *));
  162. __EXTERN short     putw    __PROTO((short, FILE *));
  163. # endif
  164.  
  165. #endif /* __STRICT_ANSI__ */
  166.  
  167.  
  168. /* aliases */
  169.  
  170. __EXTERN int    _filbuf    __PROTO((FILE *));    /* needed for getc */
  171.  
  172. #ifdef __GNUC_INLINE__
  173. #define getc(__fp) \
  174. ({   int __c; \
  175.     do { \
  176.     __c = (--__fp->_cnt >= 0) ? ((int)*__fp->_ptr++) : _filbuf(__fp); \
  177.     } while ((!(__fp->_flag & _IOBIN)) && (__c == '\r')); \
  178.     __c; \
  179. })
  180. #else
  181. #define    getc(fp)        fgetc(fp)
  182. #endif
  183.  
  184. #define    ungetc            fungetc
  185. #define    putc            fputc
  186. #define    getchar()        getc(stdin)
  187. #define    ungetchar(c)        fungetc((c),stdin)
  188. #define    putchar(c)        fputc((c),stdout)
  189.  
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193.  
  194. #endif /* _STDIO_H */
  195.